<template>
  <div class="element-plus-demo">
    <h2>Element Plus 组件演示</h2>
    
    <!-- 按钮组件 -->
    <div class="demo-section">
      <h3>按钮组件</h3>
      <el-button type="primary">主要按钮</el-button>
      <el-button type="success">成功按钮</el-button>
      <el-button type="warning">警告按钮</el-button>
      <el-button type="danger">危险按钮</el-button>
      <el-button type="info">信息按钮</el-button>
    </div>

    <!-- 表单组件 -->
    <div class="demo-section">
      <h3>表单组件</h3>
      <el-form :model="form" label-width="120px">
        <el-form-item label="用户名">
          <el-input v-model="form.username" placeholder="请输入用户名"></el-input>
        </el-form-item>
        <el-form-item label="邮箱">
          <el-input v-model="form.email" placeholder="请输入邮箱"></el-input>
        </el-form-item>
        <el-form-item label="城市">
          <el-select v-model="form.city" placeholder="请选择城市">
            <el-option label="北京" value="beijing"></el-option>
            <el-option label="上海" value="shanghai"></el-option>
            <el-option label="广州" value="guangzhou"></el-option>
          </el-select>
        </el-form-item>
        <el-form-item>
          <el-button type="primary" @click="onSubmit">提交</el-button>
          <el-button>取消</el-button>
        </el-form-item>
      </el-form>
    </div>

    <!-- 消息提示 -->
    <div class="demo-section">
      <h3>消息提示</h3>
      <el-button @click="showMessage">显示消息</el-button>
      <el-button @click="showNotification">显示通知</el-button>
    </div>
  </div>
</template>

<script setup>
import { reactive } from 'vue'
import { ElMessage, ElNotification } from 'element-plus'

const form = reactive({
  username: '',
  email: '',
  city: ''
})

const onSubmit = () => {
  ElMessage.success('表单提交成功！')
}

const showMessage = () => {
  ElMessage.info('这是一个信息提示')
}

const showNotification = () => {
  ElNotification({
    title: '成功',
    message: '这是一个成功提示的文案',
    type: 'success'
  })
}
</script>

<style scoped>
.element-plus-demo {
  padding: 20px;
  max-width: 800px;
  margin: 0 auto;
}

.demo-section {
  margin-bottom: 30px;
  padding: 20px;
  border: 1px solid #ebeef5;
  border-radius: 4px;
}

.demo-section h3 {
  margin-top: 0;
  color: #303133;
  border-bottom: 2px solid #409eff;
  padding-bottom: 10px;
}

.el-button {
  margin-right: 10px;
  margin-bottom: 10px;
}

.el-form-item {
  margin-bottom: 18px;
}
</style>
